<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/view/system/common/head.jsp"%>
<style>
.leftTd1{
   width:20%;
   text-align:right;
 }
 .rightTd{
   width:26%;
   text-align:left;
 }
</style>
<body>
	<form id="groupAddForm" name="groupAddForm" method="post">
		<div id="p" class="easyui-panel" title="添加分组" 
			fit="true" style="padding: 10px; background: #fafafa;text-align:center;">
			<fieldset>
				<legend style="color: blue;font-size:1.5" >上级分组信息</legend>
				<table class="infoTable">
					<tr>
						<td class="leftTd1">
							<input type="hidden" name="parentid" value="${parentGroup.id}" />
							<input type="hidden" name="level" value="${parentGroup.level+1}" />
							上级分组名称：
						</td>
						<td class="rightTd"> ${parentGroup.name} </td>
						<td class="leftTd1"> 上级分组编码： </td>
						<td class="rightTd colrRed"> ${parentGroup.code} </td>
					</tr>
				</table>
			</fieldset>
			<fieldset>
				<legend style="color: blue;font-size:1.5" >
					子分组信息
				</legend>
				<table class="infoTable">
					<tr>
						<td class="leftTd1">
							分组类型 ：
						</td>
						<td  class="redText">
					<c:choose>
					<c:when test="${parentGroup.level == 1}">
                         <input type="hidden" name="type" value="1" />总分组
					</c:when>
					<c:when test="${parentGroup.level > 1}">
                         <input type="hidden" name="type" value="2" />子分组
					</c:when>
					</c:choose>
					 
					</td>
					</tr>
					<tr>
						<td class="leftTd1">
							分组名称 <span class="colrRed"> * </span>：
						</td>
						<td class="rightTd">
							<input type="text" id="newGroup_name" name="name"
								MaxLength="30" class="easyui-validatebox myinput" 
								required="true" validType="length[1,30]" maxlength=30
								missingMessage="请输入分组名称"  placeholder="请输入分组名称" />
						</td>
					</tr>
					
					<tr>
					<td class="leftTd1">
							分组编码<span class="colrRed"> * </span>：
						</td>
						<td class="rightTd"> <!-- validType="remote['checkGroupCode.action','groupCode']" -->
							<input type="text" id="newGroup_code" name="code"
								class="easyui-validatebox myinput"  maxlength="10"
								required="true"  missingMessage="请输入分组编码"  placeholder="请输入分组编码"/>
						</td>
					</tr>
					
					<tr>
						<td class="leftTd1">
							分组描述 ：
						</td>
						<td >
							<textarea class="easyui-validatebox" id="newGroup_descr"
								name="descr"  rows="3"
								maxlength="160" cols="50" ></textarea>
						</td>
					</tr>
					
					<!--<tr>
						<td class="leftTd1"> 添加子分组 ： </td>
						 <td >
					      <label >可以添加</label>   
                          <input type="radio" id="childState1" name="childstate" value="1" checked="checked"/>
                          <label >无法添加</label>   
                          <input type="radio" id="childState2" name="childstate" value="2"/>
 	               </td>
 	               </tr> -->
				</table>
			</fieldset>
			<div style="text-align:center;padding-top:10px;">
				
				<a class="easyui-linkbutton myLink" iconCls="icon-ok"
					onclick="submitForm()">新增</a>
				&nbsp;&nbsp;&nbsp;
				<a  class="easyui-linkbutton myLink" iconCls="icon-undo"
					onclick="resetFrom()">重置</a>
			</div>
		</div>
	</form>
</body>
<script>
//重置
function resetFrom() {
	$("#groupAddForm").form("reset");
}

//页面提交
function submitForm() {
	//判断参数是否为空
	var valid = $('#groupAddForm').form('validate');
	if (valid) {
		var param = $('#groupAddForm').serializeJson(true);
		$.axs("usergroup/doGroupAdd.action", param, 
                function(data){
			if(data.status == 1){
				$.messager.alert("提示信息",
						data.msg, 'info', function() {
					parent.$("#groupTreegrid").treegrid('reload');
				resetFrom();
				});
			}else{
				$.messager.alert("提示信息", data.msg, 'error');
			}
		});
	/* 	//获取页面上所有的参数
		var param = getFormElementsForUrl();
		//提交后台处理  
		$.post("doGroupAdd.action" + param, callbackAdd); */
	}
}

function callbackAdd(date) {
	if (date != "") {
		var json = eval("(" + date + ")");
		if (json.records[0].messageCode == messageCodeSuccess) {
			$.messager.alert("<s:text name='mes.message'/>", json.records[0].messageDesc, 'info', function() {
				parent.$("#groupTreegrid").treegrid('reload');
				resetFrom();
			});
		} else {
			$.messager.alert("<s:text name='mes.message'/>", json.records[0].messageDesc, 'error');
		}
	}
}
</script>
</html>